package com.shrw.duke.serialport.port;

import com.odm.OdmUtil;
import com.shrw.duke.serialport.listener.PortDataListener;
import com.shrw.duke.serialport.shengbenserial.port.BasewinPort;

/**
 * Created by rw-duke on 2018/5/21.
 */

public class ShengAbsPort extends AbsPort {
    private BasewinPort mPort;
    @Override
    public void initPort() {
        mPort = BasewinPort.getInstance();
    }

    @Override
    public void open() {
        mPort.start();
    }

    @Override
    public boolean isOpen() {
        return mPort.isOpen();
    }

    @Override
    public void close() {
        mPort.stop();
    }

    @Override
    public void send(String cmd) {
        send(OdmUtil.hexStringToBytes(cmd));
    }

    @Override
    public void send(byte[] cmd) {
        mPort.sendCommd(cmd);
    }

    @Override
    public void setReturnData(PortDataListener dataListener) {
        mPort.setReadReturnDataListener(dataListener);
    }

    @Override
    public void destroy() {
        mPort = null;
    }


}
